package com.itheima.controller;

import com.itheima.service.FreeMarkerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 根据模板生成静态页面
 */
@RestController
@Slf4j
public class FreeMarkerController {

    @Autowired
    private FreeMarkerService freeMarkerService;

    /**
     * 生成套餐列表的静态页面
     */
    @GetMapping("/freeSetmeal")
    public void freeSetmeal(){
        log.info("开始生成静态页面: 套餐列表页面");
        freeMarkerService.generateSetmealFile("mobile_setmeal");
    }

    /**
     * 生成套餐详情的静态页面
     */
    @GetMapping("/freeSetmealInfo/{id}")
    public void freeSetmealInfo(@PathVariable Integer id){
        log.info("开始生成静态页面: 套餐详情页面");
        freeMarkerService.generateSetmealInfoFile("mobile_setmeal_detail", id);
    }

}
